package com.qf.dao.daoimpl;

import com.qf.dao.CategoryDao;
import com.qf.pojo.Category;
import com.qf.utils.dbutilUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

/**
 * @author Mr.Liu
 * @date 2021/11/24 21:08
 */

public class CategoryDaoImpl implements CategoryDao {
    /**
     *查找所有分类信息
     */
    @Override
    public List<Category> findAllCategory() throws SQLException {
        QueryRunner qr = new QueryRunner(dbutilUtils.getDataSource());
        String sql = "select * from category;";
        List<Category> list = qr.query(sql, new BeanListHandler<Category>(Category.class));
        return list;
    }


}
